package com.cj.demo3.controller;

import com.cj.demo3.pojo.Student;
import com.cj.demo3.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController

public class StudentController {
        @Autowired
    StudentService studentService;
    @GetMapping("findAll")
    public List<Student> findAll(){
        return studentService.findAll();
}
    @GetMapping("findById/{cid}")
    public Student findById(@PathVariable Integer cid){
        return studentService.findById(cid);
    }
    @PutMapping("update")
    public Student update(@RequestBody Student student){
        return studentService.update(student);
    }
    @DeleteMapping("delete/{cid}")
    public Student delete(@PathVariable Integer cid){
        return studentService.delete(cid);
    }
    @PutMapping("save")
    public Student save(@RequestBody Student student){
        return studentService.save(student);
    }
}
